public class kaohesan{
	static void swap(int a[],int i,int j){
		int temp;
		temp=a[i];
		a[i]=a[j];
		a[j]=temp;
	}
	static int kaohesan(int a[],int left,int right){
		int pivot=a[right];
		int tail=left - 1;
		for (int i=left;i<right;i++){
			if (a[i]<=pivot){
				swap(a,++tail,i);
			}
		}
		swap(a,tail+1,right);
		return tail + 1;
	}
	static void quickSort(int a[],int left,int right){
		if (left>=right)
			return;
		int pivotIndex=kaohesan(a,left,right);
		quickSort(a,left,pivotIndex - 1);
		quickSort(a,pivotIndex+1,right);
	}
	public static void main(String args[]){
		int a[]={15,1,2,5,8,15,1,2,5,38};
		int length=a.length-1;
		quickSort(a,0,length);
		for (int i=0; i<a.length; i++){
			System.out.print(" " + a[i]);
		}
	}
}